package com.cf.r944_ak;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class f {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int t = Integer.parseInt(br.readLine().trim());
        StringBuilder sb = new StringBuilder();
        
        while (t-- > 0) {
            int r = Integer.parseInt(br.readLine().trim());
            long r2 = 1L * r * r;
            long r1_2 = 1L * (r + 1) * (r + 1);
            
            long S = 0;
            for (int x = 1; x <= r; x++) {
                long x2 = 1L * x * x;

                long L_sq = r2 - x2;
                int L;
                if (L_sq <= 0) {
                    L = 1;
                } else {
                    L = (int) Math.ceil(Math.sqrt(L_sq));
                }

                long U_sq = r1_2 - x2 - 1;
                if (U_sq < 0) {
                    continue;
                }
                int U = (int) Math.floor(Math.sqrt(U_sq));
                
                if (U >= L) {
                    S += (U - L + 1);
                }
            }
            
            long answer = 4 * S + 4;
            sb.append(answer).append('\n');
        }
        
        System.out.print(sb.toString());
    }
}
